from django.db import models

from social.account.models import User
from social.utils.models import BaseModel


class Notification(BaseModel):
    TYPE_LIKE = 1
    TYPE_COMMENT = 2
    content = models.CharField(max_length=100, null=True)
    from_user = models.ForeignKey(User, related_name='notification_from', on_delete=models.CASCADE)
    user = models.ForeignKey(User, related_name='notification', on_delete=models.CASCADE)
    type = models.CharField(max_length=10)
    link = models.CharField(max_length=100)
    thumb = models.CharField(max_length=200)

    class Meta:
        index_together = [
            ('user', 'type', 'created_at')
        ]


class NotificationRead(BaseModel):
    user = models.OneToOneField(User, related_name='un_read', on_delete=models.CASCADE)
    new_fans = models.IntegerField(default=0)
    new_visitor = models.IntegerField(default=0)
    new_post_msg = models.IntegerField(default=0)
